using BuildingBlocks.Domain;
using Mediator;

namespace BuildingBlocks.Application.Messaging;

public abstract class DomainEventHandler<TDomainEvent>
    : IDomainEventHandler<TDomainEvent>, INotificationHandler<TDomainEvent>
    where TDomainEvent : IDomainEvent
{
    public abstract ValueTask Handle(TDomainEvent domainEvent, CancellationToken cancellationToken = default);

    public ValueTask Handle(IDomainEvent domainEvent, CancellationToken cancellationToken = default) =>
        Handle((TDomainEvent)domainEvent, cancellationToken);
}
